import { IToolTip } from "../../../../../com/mui/manager/IToolTip";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { Language } from "../../../../../extend/language/Language";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GroupMemberData } from "../arenaCrossData/GroupMemberData";
import { SArenaCrossProcessRes } from "../../../../../Message/Public/SArenaCrossProcessRes";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { CareerConfig } from "../../../resource/CareerConfig";
import { AvatarInfo } from "../../../resource/info/AvatarInfo";
import { AvatarType } from "../../../resource/info/AvatarType";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { ArenaCrossUtil } from "../ArenaCrossUtil";
type int = number;
//class GroupPlayerTips
    
    export  class GroupPlayerTips /* flash.display.Sprite */ implements IToolTip
    {
        constructor()
        {
            
            this._aryBattleSp = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 255, 320, this, "ToolTipBg");
            var loc1=GlobalStyle.textFormat1;
            loc1.size = 13;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._tfName = ObjCreate.createTextField("", 80, 18, 105, 20, this, loc1);
            var loc2=new Object /* flash.display.Bitmap */();
            loc2.x = 21;
            loc2.y = 46;
            this.addChild(loc2);
            LoaderHelp.setBitmapdata("Friend_Bg_Head.swf", loc2);
            var loc3=new Object /* flash.display.Sprite */();
            loc3.buttonMode = true;
            loc3.x = 38;
            loc3.y = 63;
            this.addChild(loc3);
            this._headImage = new Object /* flash.display.Bitmap */();
            loc3.addChild(this._headImage);
            ObjCreate.createTextField(Language.getString(44294), 136, 62, 50, 20, this, GlobalStyle.textFormat6);
            this._tfServer = ObjCreate.createTextField("", 186, 62, 80, 20, this);
            this._tfLevel = ObjCreate.createTextField("", 136, 82, 70, 20, this, GlobalStyle.textFormat6);
            this._tfCareer = ObjCreate.createTextField("", 200, 82, 50, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(44295), 136, 102, 50, 20, this, GlobalStyle.textFormat6);
            this._tfPower = ObjCreate.createTextField("", 186, 102, 70, 20, this, GlobalStyle.textFormat6);
            this._tfGroup = ObjCreate.createTextField("", 136, 122, 60, 20, null, GlobalStyle.textFormat6);
            this._tfGroup.visible = false;
            this._tfGroup.visible = false;
            this._tfGroup.visible = false;
            var loc4;
            (loc4 = GlobalStyle.textFormatGreen).size = 20;
            loc4.font = FontUtil.EmbedNumberName;
            this._battleSp1 = this.createBattleSp(17, 200);
            this._battleSp2 = this.createBattleSp(17, 224);
            this._battleSp3 = this.createBattleSp(17, 248);
            this._battleSp4 = this.createBattleSp(17, 272);
            LoaderHelp.addResCallBack(ResFileConst.ArenaCrossGroupSendFlowers, this.onResCompl);
            return;
        }

        /* internal  */onResCompl(): void
        {
            return;
        }

        /* internal  */createBattleSp(arg1: int, arg2: int): BattleSp
        {
            var loc1=null;
            loc1 = new BattleSp();
            loc1.x = arg1;
            loc1.y = arg2;
            this.addChild(loc1);
            this._aryBattleSp.push(loc1);
            return loc1;
        }

        public set data(arg1)
        {
            if (typeof arg1 === "groupmemberdata") 
            {
                this._groupMember = arg1 as GroupMemberData;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            var i: int;
            var battleSp: BattleSp;
            var processRes: SArenaCrossProcessRes;

            var loc1;
            battleSp = null;
            processRes = null;
            this._tfName.text = this._groupMember.arenaCrossGroupMember.name;
            this._tfServer.text = EntityUtil.getProxyName(this._groupMember.arenaCrossGroupMember.entityId);
            this._tfLevel.text = "LV." + this._groupMember.arenaCrossGroupMember.level;
            this._tfCareer.text = CareerConfig.instance.getInfoByCode(this._groupMember.arenaCrossGroupMember.career).name;
            this._tfPower.text = this._groupMember.arenaCrossGroupMember.warfare.toString();
            this._tfGroup.text = Language.getStringByParam(44296, this._groupMember.groupId.toString());
            i = 0;
            while (i < this._aryBattleSp.length) 
            {
                if (i < this._groupMember.arenaCrossGroupMember.reses.length) 
                {
                    battleSp = this._aryBattleSp[i] as BattleSp;
                    processRes = this._groupMember.arenaCrossGroupMember.reses[i] as SArenaCrossProcessRes;
                    battleSp.updateData(processRes);
                }
                else 
                {
                    break;
                }
                ++i;
            }
            AvatarInfo.getAvatar(this._groupMember.arenaCrossGroupMember.camp, this._groupMember.arenaCrossGroupMember.sex, AvatarType.BIG, (arg1: ImageInfo): void
            {
                _headImage.bitmapData = arg1.bitmapData;
                return;
            }, this._groupMember.arenaCrossGroupMember.avatarId)
            return;
        }

        /* internal */ /* var */_groupMember: GroupMemberData;

        /* internal */ /* var */_tfName: Object /* flash.text.TextField */;

        /* internal */ /* var */_headImage: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfServer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCareer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfPower: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfGroup: Object /* flash.text.TextField */;

        /* internal */ /* var */_battleSp1: BattleSp;

        /* internal */ /* var */_battleSp2: BattleSp;

        /* internal */ /* var */_battleSp3: BattleSp;

        /* internal */ /* var */_battleSp4: BattleSp;

        /* internal */ /* var */_aryBattleSp: Array<any>;
    }
}


class BattleSp extends flash.display.Sprite
{
    public BattleSp()
    {
        super();
        this.init();
        return;
    }

    public init(): void
    {
        this._tfBattleNum = ObjCreate.createTextField("", 0, 0, 70, 20, this, GlobalStyle.textFormatGreen);
        this._tfBattleRank = ObjCreate.createTextField("", 70, 0, 70, 20, this, GlobalStyle.textFormatGreen);
        this._tfBattleWinPer = ObjCreate.createTextField("", 145, 0, 80, 20, this, GlobalStyle.textFormatGreen);
        return;
    }

    public updateData(arg1: SArenaCrossProcessRes): void
    {
        this._tfBattleNum.text = ArenaCrossUtil.getTextByProcess(arg1.process);
        this._tfBattleRank.text = Language.getStringByParam(44297, arg1.rank.toString());
        this._tfBattleWinPer.text = Language.getStringByParam(44298, (arg1.winPer * 1 / 100).toFixed(2));
        return;
    }

    /* internal */ /* var */_tfBattleNum: Object /* flash.text.TextField */;

    /* internal */ /* var */_tfBattleRank: Object /* flash.text.TextField */;

    /* internal */ /* var */_tfBattleWinPer: Object /* flash.text.TextField */;
